#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int year, month;
    cin >> year >> month;
    if (month == 2)
    {
        if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
        {
            cout << 29 << endl;
        }
        else
        {
            cout << 28 << endl;
        }
    }
    else if (month == 4 || month == 6 || month == 9 || month == 11)
    {
        cout << 30 << endl;
    }
    else
    {
        cout << 31 << endl;
    }
}